package com.lmh.service;

import com.lmh.dao.LoginMapper;
import com.lmh.pojo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


@Service
@Transactional
public class LoginServiceImpl implements LoginService{

    @Autowired
    private LoginMapper loginMapper;



    @Override
    public int adduser(String userName, String userId, String email, String password) {
        User user=new User();
        user.setUserId(userId);
        user.setEmail(email);
        user.setPassword(password);
        int i=loginMapper.addregedit(user);
        Userinfo userinfo=new Userinfo();
        userinfo.setUserId(userId);
        userinfo.setUserName(userName);
        userinfo.setEmail(email);
        int j=loginMapper.addinfo(userinfo);
        return i+j;
    }

    @Override
    public User login(String email, String password) {
        return loginMapper.login(email,password);
    }

    @Override
    public List<Userinfo> edan(String email, String userName) {
        return loginMapper.edan(email,userName);
    }

    @Override
    public Userinfo infoall(String userId) {
        System.out.println("service:"+userId);
        return loginMapper.infoall(userId);
    }

    @Override
    public List<Provines> address() {
        return loginMapper.address();
    }

    @Override
    public int updatepw(User u) {
        return loginMapper.updatepw(u);
    }

    @Override
    public List<Cities> citiesquan(String provinceid) {
        return loginMapper.citiesquan(provinceid);
    }

    @Override
    public List<Areas> arasquan(String cityid) {
        return loginMapper.arasquan(cityid);
    }

    @Override
    public int updateinfo(Userinfo userinfo) {
        return loginMapper.updateinfo(userinfo);
    }
}
